﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CNRegex.Biz.BizAccess;
using CNRegex.Web.Base;
using CNRegex.Entity;
using CNRegex.Enum;
using CNRegex.Biz;

namespace CNRegex.Web.Controllers
{
	public class AdminRegexBlogCatalogController : BaseController
	{
		private BizRegexUserBlogCatalog bizRegexUserBlogCatalog;

		public AdminRegexBlogCatalogController()
		{
			bizRegexUserBlogCatalog = BizFactory.Get<BizRegexUserBlogCatalog>();
		}

		//
		// GET: /AdminBlogCatalog/
		public ActionResult Index()
		{
			IList<RegexUserBlogCatalog> list = bizRegexUserBlogCatalog.List(x => x.OrderIndex, Enum.EnumOrder.ASC);
			return View(list);
		}

		[HttpPost]
		public ActionResult Save(RegexUserBlogCatalog model)
		{
			model.CreateDate = DateTime.Now;
			bizRegexUserBlogCatalog.SaveOrUpdate(model);
			return Content(EnumOperationState.Success.ToString());
		}
		[HttpPost]
		public ActionResult Delete(Guid id)
		{
			bizRegexUserBlogCatalog.DeleteByID(id, NHibernate.NHibernateUtil.Guid);
			return Content(EnumOperationState.Success.ToString());
		}
	}
}
